package com.byd.android.agreement.message;

import com.byd.android.VideoPlayer.LoadedImage;
import com.byd.android.agreement.BaseMessage;
import com.google.gson.JsonObject;

public class Video extends BaseMessage {
    private int id = 1;  //标识码
    private int duration = 0;//时长
    private String artist = null;//表演者
    private String videoName = null;//视频名
    private String data;//文件路径
    private LoadedImage image;


    public Video(){}
    public Video(int id, int duration, String artist, String videoName, String data) {
        this.id = id;
        this.duration = duration;
        this.artist = artist == null ? "" : artist;
        this.videoName = videoName == null ? "" :videoName;
        this.data = data == null ? "" : data;

    }
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String getArtist() {
        return artist;
    }

    public void setArtist(String artist) {
        this.artist = artist == null ? "" : artist;
    }

    public String getVideoName() {
        return videoName;
    }

    public void setVideoName(String videoName) {
        this.videoName = videoName == null ? "" : videoName;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data == null ? "" : data;
    }

    public LoadedImage getImage(){
        return image;
    }

    public void setImage(LoadedImage image){
        this.image = image;
    }


    @Override
    public String toString() {
        return "Video{" +
                "id=" + id +
                ", duration=" + duration +
                ", artist='" + artist + '\'' +
                ", videoName='" + videoName + '\'' +
                ", data='" + data + '\'' +
                '}';
    }
    public static Video parseJson(String jstr) {
        Video video = new Video();
        JsonObject Jobj = mParser.parse(jstr).getAsJsonObject();
        video.setId(Jobj.get("id").getAsInt());
        video.setDuration(Jobj.get("duration").getAsInt());
        video.setArtist(Jobj.get("artist").getAsString());
        video.setVideoName(Jobj.get("videoName").getAsString());
        video.setData(Jobj.get("data").getAsString());

        return video;
    }
}

